//登录
function cambiar_login() {
    // alert(document.getElementById("login_name"));
    document.querySelector('.cont_forms').className = "cont_forms cont_forms_active_login";
    document.querySelector('.cont_form_login').style.display = "block";
    document.querySelector('.cont_form_login').style.border = " 20 red";
    document.querySelector('.cont_form_sign_up').style.opacity = "0";

    setTimeout(function () {
        document.querySelector('.cont_form_login').style.opacity = "1";
    }, 400);

    setTimeout(function () {
        document.querySelector('.cont_form_sign_up').style.display = "none";
    }, 200);

}
//登录验证
function login_submit() {
    // alert(1);
    var userLoginName = $("#login_name").val();
    // alert(userLoginName)
    var userLoginPasswd = $("#login_pw").val();
    // alert(userLoginPasswd)
    $.ajax({
        method: "POST",
        url: '/loginServlet',
        // async: false,
        data: {
            "userLoginName": userLoginName,
            "userLoginPasswd":userLoginPasswd
        },
        success: function (result) {
            // alert(result)
            if (result == "1") {
                alert("登录成功！");
                window.location.href = "../views/menu.jsp"
            }else if (result == "2"){
                alert("密码不正确！");
                window.location.href = "../views/init.jsp"
            }else if (result == "3"){
                alert("用户不存在！");
                window.location.href = "../views/init.jsp"
            }
        },
        error: function () {
            alert("出现了错误");
        }
    });
}
//注册验证
function sign_submit() {
    // alert(1);
    var userSignName = $("#sign_name").val();
    // alert(userSignName)
    var userSignPasswd = $("#sign_pass").val();
    // alert(userSignPasswd)
    var userSignPasswd2 = $("#sign_pass2").val();
    // alert(userSignPasswd2)
    $.ajax({
        method: "POST",
        url: '/registerSer',
        data: {
            "userSignName": userSignName,
            "userSignPasswd":userSignPasswd,
            "userSignPasswd2":userSignPasswd2
        },
        success: function (result) {
            // alert(result)
            if (result == "2") {
                alert("密码不一致！");
                window.location.href = "../views/init.jsp"
            }else if (result == "3"){
                alert("用户名已存在，请登录！");
                window.location.href = "../views/init.jsp"
            }else if (result == "4"){
                alert("注册成功！请登录!");
                window.location.href = "../views/init.jsp"
            }
        },
        error: function () {
            alert("出现了错误");
        }
    });
}



function cambiar_sign_up(at) {
    document.querySelector('.cont_forms').className = "cont_forms cont_forms_active_sign_up";
    document.querySelector('.cont_form_sign_up').style.display = "block";
    document.querySelector('.cont_form_login').style.opacity = "0";

    setTimeout(function () {
        document.querySelector('.cont_form_sign_up').style.opacity = "1";
    }, 100);

    setTimeout(function () {
        document.querySelector('.cont_form_login').style.display = "none";
    }, 400);


}

function ocultar_login_sign_up() {

    document.querySelector('.cont_forms').className = "cont_forms";
    document.querySelector('.cont_form_sign_up').style.opacity = "0";
    document.querySelector('.cont_form_login').style.opacity = "0";

    setTimeout(function () {
        document.querySelector('.cont_form_sign_up').style.display = "none";
        document.querySelector('.cont_form_login').style.display = "none";
    }, 500);

}




